package com.smartsleep;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageButton;

public class CircleFragment extends Fragment implements OnClickListener{
	 
	 Button bt_share;
	 Button bt_solution;
	 Button bt_insomnia;
	 Button bt_dream;
	 Button bt_disease;
	 Button bt_allnight;
	 Button bt_sports;
	 Button bt_search;
	 Button friend;
	 Button sharequan;
	 @Override
	 public View onCreateView(LayoutInflater inflater, ViewGroup container,  
	         Bundle savedInstanceState) {  
	     View view = inflater.inflate(R.layout.fragment_circle, container, false);  
	     return view;  
	     
	 }
	@Override
	public void onActivityCreated(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onActivityCreated(savedInstanceState);
		bt_share=(Button) getView().findViewById(R.id.bt_share);
		bt_allnight=(Button) getView().findViewById(R.id.bt_allnight);
		bt_search=(Button) getView().findViewById(R.id.bt_search);
		bt_solution=(Button) getView().findViewById(R.id.bt_solution);
		bt_insomnia=(Button) getView().findViewById(R.id.bt_insomnia);
		bt_dream=(Button) getView().findViewById(R.id.bt_dream);
		bt_sports=(Button) getView().findViewById(R.id.bt_sports);
		bt_disease=(Button) getView().findViewById(R.id.bt_disease);
		friend=(Button) getView().findViewById(R.id.friend);
		sharequan=(Button) getView().findViewById(R.id.sharequan);
		
		bt_share.setOnClickListener(this);
		bt_allnight.setOnClickListener(this);
		bt_search.setOnClickListener(this);
		bt_solution.setOnClickListener(this);
		bt_insomnia.setOnClickListener(this);
		bt_dream.setOnClickListener(this);
		bt_sports.setOnClickListener(this);
		bt_disease.setOnClickListener(this);
		friend.setOnClickListener(this);
		sharequan.setOnClickListener(this);

	}
	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		switch(v.getId()){
		case R.id.bt_share:
			share();
			break;
		case R.id.bt_search:
			openSearch();break;
		case R.id.bt_allnight:
			selectiontopic(4);break;
		case R.id.bt_disease:
			selectiontopic(5);break;
		case R.id.bt_dream:
			selectiontopic(3);break;
		case R.id.bt_solution:
			selectiontopic(1);break;
		case R.id.bt_sports:
			selectiontopic(6);break;
		case R.id.bt_insomnia:
			selectiontopic(2);break;
		case R.id.friend:
			openFriendList();break;
		case R.id.sharequan:
			openShareQuan();break;
		default:
			break;
		}
	}
	private void openShareQuan() {
		// TODO Auto-generated method stub
		Intent intent=new Intent(getActivity(), SharePageActivity.class);
		startActivity(intent);
		
	}
	private void openFriendList() {
		// TODO Auto-generated method stub
		Intent intent=new Intent(getActivity(), FriendListActivity.class);
		startActivity(intent);
		
	}
	private void share() {
		// TODO Auto-generated method stub
		Intent intent=new Intent(getActivity(), SendShareActivity.class);
		startActivity(intent);
		
	}
	private void selectiontopic(int index) {
		Intent intent=new Intent(getActivity(),TopicListActivity.class);
		intent.putExtra("indexmessage", index);
		startActivity(intent);
	}
	private void openSearch(){
		Intent intent=new Intent(getActivity(),SearchActivity.class);
		startActivity(intent);
	}
	
}
